#include "jobsinterfaceimpl.h"

#include "kdcreadfileinfojob.h"
#include "thumbnailjob.h"

JobsInterfaceImpl::JobsInterfaceImpl( QObject *aParent ) : QObject( aParent )
{

}

JobsInterfaceImpl::~JobsInterfaceImpl()
{

}

KDCMovieMetaData* JobsInterfaceImpl::getFileInfo( const QString &aFile, QString &aError )
{
	KDCReadFileInfoJob job( aFile, this );
	if ( job.exec() && job.video() )
		return new KDCMovieMetaData( aFile, job.video(), job.audio() );
	aError = job.errorText();
	return NULL;
}

KDCFrameJobInterface* JobsInterfaceImpl::scaledThumbnailJob( const QString &aMovieFile, int aPos )
{
	return new ThumbnailJob( aMovieFile, aPos, false, this );
}

QPixmap JobsInterfaceImpl::getScaledThumbnail( const QString &aMovieFile, int aPos, QString &aError )
{
	ThumbnailJob job( aMovieFile, aPos, true, this );
	if ( !job.exec() )
		aError = job.errorText();
	else
		return job.resultFrame();
	return QPixmap();
}

KDCFrameJobInterface* JobsInterfaceImpl::thumbnailJob( const QString &aMovieFile, int aPos )
{
	return new ThumbnailJob( aMovieFile, aPos, false, this );
}

QPixmap JobsInterfaceImpl::getThumbnail( const QString &aMovieFile, int aPos, QString &aError )
{
	ThumbnailJob job( aMovieFile, aPos, false, this );
	if ( !job.exec() )
		aError = job.errorText();
	else
		return job.resultFrame();
	return QPixmap();
}
